import unittest
from alg import Solution
from gen import generate_test_case

class TestMaxArea(unittest.TestCase):
    def test_example_1(self):
        """测试示例1"""
        solution = Solution()
        self.assertEqual(solution.maxArea([1,8,6,2,5,4,8,3,7]), 49)

    def test_example_2(self):
        """测试示例2"""
        solution = Solution()
        self.assertEqual(solution.maxArea([1,1]), 1)

    def test_random_case(self):
        """测试随机生成的案例"""
        solution = Solution()
        test_case = generate_test_case()
        # 简单验证结果的合理性
        result = solution.maxArea(test_case)
        self.assertGreaterEqual(result, 0)
        # 确保结果不超过最大可能值
        max_possible = (len(test_case) - 1) * max(test_case)
        self.assertLessEqual(result, max_possible)

if __name__ == "__main__":
    unittest.main()    